package cn.itsource.pethome.org.controller;

import cn.itsource.pethome.basic.util.AjaxResult;
import cn.itsource.pethome.basic.util.PageList;
import cn.itsource.pethome.org.domain.Department;
import cn.itsource.pethome.org.domain.Employee;
import cn.itsource.pethome.org.domain.Shop;
import cn.itsource.pethome.org.query.DepartmentQuery;
import cn.itsource.pethome.org.query.EmployeeQuery;
import cn.itsource.pethome.org.query.ShopQuery;
import cn.itsource.pethome.org.service.IEmployeeService;
import cn.itsource.pethome.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 描述:
 * @date: 2020/8/9 14:22
 * @author: summer
 * version: 1.0
 */
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private IShopService shopService;

    @PostMapping("/settledIn")
    public AjaxResult settledIn(@RequestBody Shop shop){
        try {
            shopService.settledIn(shop);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"注册失败");
        }
    }

    @PatchMapping
    public PageList<Shop> loadAll(@RequestBody ShopQuery shopQuery){
        //departmentQuery.toString();
        //System.out.println(departmentQuery);
        return shopService.loadAll(shopQuery);
    }

    @PostMapping
    public AjaxResult update(@RequestBody Shop shop){
        System.out.println("通过测试" +shop);
        try {
            System.out.println(shop.getAdmin());
            shopService.update(shop);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"修改失败" + e.getMessage());
        }
    }
}
